package com.gitee.smalllog.server.client;

import com.alibaba.fastjson.JSONObject;
import com.gitee.smalllog.core.client.AbstractServerClient;
import com.gitee.smalllog.stored.mapper.LogMapper;
import com.gitee.smalllog.stored.model.LogEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.util.List;

/**
 * className：ElasticLowerClient
 * description：ElasticLowerClient
 *
 * @author ddzhan
 * @version 1.0.0
 */
@Component
@Slf4j
public class DataBaseClient extends AbstractServerClient {

    @Autowired
    LogMapper logMapper;

    @Override
    public void insertListLog(List<String> list, String baseIndex, String type) throws Exception {
        list.forEach(data->{
            LogEntity logEntity = null;
            logEntity = JSONObject.toJavaObject(JSONObject.parseObject(data),LogEntity.class);
            logMapper.insert(logEntity);
        });

    }

    @Override
    public void insertListTrace(List<String> list, String baseIndex, String type) throws Exception {

    }

    @Override
    public void insertListComm(List<String> list, String baseIndex, String type) throws Exception {

    }

    @Override
    public boolean deleteIndex(String index) throws IOException {
        return false;
    }

    @Override
    public String get(String url, String queryStr) throws Exception {
        return null;
    }

    @Override
    public String get(String indexStr, String queryStr, String from, String size) throws Exception {
        return null;
    }

    @Override
    public String group(String indexStr, String queryStr) throws Exception {
        return null;
    }

    @Override
    public String cat(String index) {
        return null;
    }

    @Override
    public boolean creatIndice(String indice, String type) {
        return false;
    }

    @Override
    public boolean setMapping(String indice, String type) {
        return false;
    }

    @Override
    public boolean creatIndiceTrace(String indice, String type) {
        return false;
    }

    @Override
    public boolean existIndice(String indice) {
        return false;
    }

    @Override
    public String getVersion() {
        return null;
    }

    @Override
    public boolean creatIndiceNomal(String indice, String type) {
        return false;
    }

    @Override
    public List<String> getExistIndices(String[] indices) {
        return null;
    }

    @Override
    public void close() {

    }

    @Override
    public boolean addShards(Long shardCount) {
        return false;
    }
}
